package com.deltabot.master.webserver;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class server extends Thread {

    public void run(){
        ServerSocket sock;
        int Port = 11111;
        System.out.println("Starting our WebServer at port " + Port);

       try {

           sock = new ServerSocket(Port);

       } catch (Exception e){
           System.out.println("Error: " + e);
           return;
       }

        // Socket created -> wait for client sockets

        for (;;){
            try {
                Socket remoteSock = sock.accept();
                // Client connected -> init responder for client
                responder clientResponder = new responder(remoteSock);
                //System.out.println("[WEBSERVER] Got pagerequest from " + remoteSock.getInetAddress().getHostAddress());
                clientResponder.start();

            } catch (IOException e) {
                System.out.println("Error: "+ e);
                return;
            }

        }



    }

}
